#include<stdio.h>
int main()
{
	int i = 0;
	for (i = 100; i < 1000; i++)
	{
		int a = i % 10;
		int b = i / 100;
		int c = (i % 100) / 10;
		int num = a * a * a + b * b * b + c * c * c;
		if (num == i)
			printf("%d ", i);
	}
	int j = 0;
	for (j = 1000; j < 10000; j++)
	{
		int d = j % 10;
		int e = j / 1000;
		int f = (j % 100) / 10;
		int g = (j % 1000) / 100;
		int sum = d * d * d * d + e * e * e * e + f * f * f * f + g * g * g * g;
		if (j == sum)
			printf("%d ", j);
	}
	int r = 0;
	for (r = 10000; r < 100000; r++)
	{
		int a = r % 10;
		int b = r / 10000;
		int c = (r % 100) / 10;
		int d = (r % 1000) / 100;
		int e = (r % 10000) / 1000;
		int maxe = a * a * a * a * a + b * b * b * b * b + c * c * c * c * c + d * d * d * d * d + e * e * e * e * e;
		if (maxe == r)
			printf("%d ", r);
	}
	return 0;
}